package platformer;

import java.awt.Dimension;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;

import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class GamePanel extends javax.swing.JPanel {
	public JLabel jLabel1;
	public JComboBox jComboBox1;
	public JButton jButton1;
	private JTextField jTextField1;
	Manager manager;
	String[] packlist;
	public String filename;

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	
	public GamePanel(String[] packlist) {
		super();
		this.packlist = packlist;
		initGUI();
	}
	
	public void setManager(Manager manager){
        filename = null;
        this.manager = manager;
    }
	
	private void initGUI() {
		try {
			setPreferredSize(new Dimension(400, 300));
			this.setSize(600, 300);
			this.setLayout(null);
			{
				jLabel1 = new JLabel();
				this.add(jLabel1);
				jLabel1.setText("jLabel1");
				jLabel1.setBounds(249, 123, 307, 14);
			}
			{
				ComboBoxModel jComboBox1Model = 
					new DefaultComboBoxModel(
							packlist);
				jComboBox1 = new JComboBox();
				this.add(jComboBox1);
				jComboBox1.setModel(jComboBox1Model);
				jComboBox1.setBounds(249, 143, 118, 21);
			}
			{
				jButton1 = new JButton();
				this.add(jButton1);
				jButton1.setText("Begin!!!");
				jButton1.setBounds(249, 170, 118, 21);
				jButton1.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						jButton1MouseClicked(evt);
					}
				});
			}
			{
				jTextField1 = new JTextField();
				this.add(jTextField1);
				jTextField1.setText("jTextField1");
				jTextField1.setBounds(584, 0, 16, 21);
				jTextField1.addKeyListener(new KeyAdapter() {
					public void keyReleased(KeyEvent evt) {
						jTextField1KeyReleased(evt);
					}
					public void keyPressed(KeyEvent evt) {
						jTextField1KeyPressed(evt);
					}
				});
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void jButton1MouseClicked(MouseEvent evt) {
		filename = jComboBox1.getSelectedItem().toString();
        System.out.println(filename);
	}
	
	private void jTextField1KeyPressed(KeyEvent evt) {
		manager.keysDown[evt.getKeyCode()] = true;
	}
	
	private void jTextField1KeyReleased(KeyEvent evt) {
		manager.keysDown[evt.getKeyCode()] = false;
	}

}
